package com.dyrs.delaytaskservice.nacos;


import com.alibaba.nacos.api.config.annotation.NacosValue;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import static org.springframework.web.bind.annotation.RequestMethod.GET;

@Controller
@RequestMapping("config")
@RefreshScope
public class ConfigController {
    @NacosValue(value = "${useLocalCache:false}", autoRefreshed = true)
    private boolean useLocalCache;

    @NacosValue(value = "${server.port: 0000}", autoRefreshed = true)
    private String server_port;

//    @NacosValue(value = "${server.port}", autoRefreshed = true)
//    private String server_port1;
//
//    @NacosValue(value = "${server.port}")
//    private String server_port2;
//
//    @Value("${server.port}")
//    private String server_port3;



    @RequestMapping(value = "/get", method = GET)
    @ResponseBody
    public boolean get() {
        System.out.println("ConfigController.get");
        System.out.println(server_port);
//        System.out.println(server_port1);
//        System.out.println(server_port2);
//        System.out.println(server_port3);
        return useLocalCache;
    }
}
